<?php
//
//	file: includes/aucp/visit_plugs.php
//	begin: 30/04/2007
//	$Author: christopher $
//	$Revision: 29 $
//	$Date: 2008-07-19 15:59:35 +0000 (Sat, 19 Jul 2008) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: last visit plugs

if (!defined('IN_PHPBB'))
{
	die("Hacking attempt");
}

class visit_header
{
	// @public page header
	function start()
	{
		global $template, $user;

		$template->assign_vars(array(
			'L_VISITED' => $user->lang('Visited'),
		);

		return;
	}
}

class visit_profile
{
	// @public view profile fields
	function view($view_user)
	{
		global $template, $user, $config;

		$template->assign_vars(array(
		   	'VISITED' => $view_user->data['user_session_time'] ? ( create_date($user->lang('DATE_FORMAT'), $view_user->data['user_session_time'], $config->data['board_timezone'])) : '--------',
		);

		return;
	}
}

class visit_members
{
	// @public memberlist init
	function start()
	{
		global $mode_types_text, $mode_types, $user;

		$mode_types_text[] = $user->lang('Sort_Visited');
		$mode_types[] = 'visitdate';

		return;
	}

	// @public modify sql
	function format_sql_detail(&$sql)
	{
		global $mode;

		$sql = str_replace('SELECT ', 'SELECT user_session_time, ', $sql);
		if($mode == 'visitdate')
		{
			$sql = str_replace('ORDER BY user_regdate', 'ORDER BY user_session_time', $sql);
		}

		return;
	}

	// @public display row
	function display($row, $switch)
	{
		global $user, $template, $config;

		// If user_session_time is zero, then user has never visited.
		if($row['user_session_time']==0)
		{
			$lastvisit = '---------';
		}
		else
		{
			$lastvisit = create_date($user->lang('DATE_FORMAT'), $row['user_session_time'], $config->data['board_timezone']);
		}

		$template->assign_lastblock_vars($switch, array(
			'VISITED' => $lastvisit,
		));

		$template->assign_vars(array(
			'L_VISITED' => $user->lang('Visited'),
		));

		return;
	}
}

?>